const FRAGMENT: WeakMap<object, DocumentFragment> = new WeakMap()

export function getFragment(key: object) {
  return FRAGMENT.get(key) || null
}

export function setFragment(key: object, value: DocumentFragment | null) {
  if (!value) {
    FRAGMENT.delete(key)
  } else {
    FRAGMENT.set(key, value)
  }
}

export function delFragment(key: object) {
  FRAGMENT.delete(key)
}
